home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / awe2-0_1.lha / awe2-0.1 / Src / RCS / SpinEvent.h,v < prev    next >
Text File  |  1989-02-23  |  2KB  |  161 lines

  1. head     3.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    grunwald:3.2; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 3.2
  10. date     89.02.20.15.37.36;  author grunwald;  state Exp;
  11. branches ;
  12. next     3.1;
  13.  
  14. 3.1
  15. date     88.12.20.13.50.19;  author grunwald;  state Exp;
  16. branches ;
  17. next     1.2;
  18.  
  19. 1.2
  20. date     88.10.30.13.06.07;  author grunwald;  state Exp;
  21. branches ;
  22. next     1.1;
  23.  
  24. 1.1
  25. date     88.09.28.22.13.44;  author grunwald;  state Exp;
  26. branches ;
  27. next     ;
  28.  
  29.  
  30. desc
  31. @@
  32.  
  33.  
  34. 3.2
  35. log
  36. @Start using Gnu library heaps for schedulers
  37. @
  38. text
  39. @// This may look like C code, but it is really -*- C++ -*-
  40. // 
  41. // Copyright (C) 1988 University of Illinois, Urbana, Illinois
  42. //
  43. // written by Dirk Grunwald (grunwald@@cs.uiuc.edu)
  44. //
  45. #ifndef SpinEvent_h
  46. #define SpinEvent_h
  47.  
  48. //
  49. //    Implement a UNIX event
  50. //
  51.  
  52. #include "SpinLock.h"
  53.  
  54. const int EventMaxTimesAround = 1000;
  55.  
  56. class SpinEvent : public SpinLock {
  57.     short generation;
  58.     short pLoops;
  59.     short state;
  60.     short garcon;    // waiters
  61. public:
  62.     SpinEvent( int pLoops = EventMaxTimesAround );
  63.     ~SpinEvent();
  64.     void rendezvous();
  65.     void waitFor();
  66.     void trigger();
  67.     void waiting();
  68.     int size();
  69. };
  70.  
  71. inline
  72. SpinEvent::SpinEvent( int l )
  73. {
  74.     pLoops = l;
  75.     state = 1;
  76.     garcon = 0;
  77. }
  78.  
  79. inline
  80. SpinEvent::~SpinEvent()
  81. {
  82. }
  83.  
  84. void
  85. SpinEvent::trigger()
  86. {
  87.     reserve();
  88.     garcon = 0;
  89.     generation++;
  90.     release();
  91. }
  92.  
  93. int
  94. SpinEvent::size()
  95. {
  96.     reserve();
  97.     int was = garcon;
  98.     release();
  99.     return(was);
  100. }
  101.  
  102. #endif
  103. @
  104.  
  105.  
  106. 3.1
  107. log
  108. @Steay version
  109. @
  110. text
  111. @@
  112.  
  113.  
  114. 1.2
  115. log
  116. @*** empty log message ***
  117. @
  118. text
  119. @d58 4
  120. a61 5
  121.     //
  122.     // No point in reserving this -- unless they've reserved the thing,
  123.     // you can't insure that the value they get makes sense anyway.
  124.     //
  125.     return(garcon);
  126. @
  127.  
  128.  
  129. 1.1
  130. log
  131. @Initial revision
  132. @
  133. text
  134. @d1 8
  135. a8 2
  136. #ifndef HardEvent_h
  137. #define HardEvent_h
  138. d14 1
  139. a14 1
  140. #include "HardSpinLock.h"
  141. d18 1
  142. a18 1
  143. class HardEvent : public HardSpinLock {
  144. d24 2
  145. a25 2
  146.     HardEvent( int pLoops = EventMaxTimesAround );
  147.     ~HardEvent();
  148. d34 1
  149. a34 1
  150. HardEvent::HardEvent( int l )
  151. d42 1
  152. a42 1
  153. HardEvent::~HardEvent()
  154. d47 1
  155. a47 1
  156. HardEvent::trigger()
  157. d56 1
  158. a56 1
  159. HardEvent::size()
  160. @
  161.